package borge.web.teamspirit.client.page.team.widgets;

import borge.web.teamspirit.client.interfaces.WidgetEventHandler;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler.WidgetEventType;

import com.google.gwt.user.client.ui.Composite;

/**
 * Superclass for all widgets that we define locally here
 * @author andreas
 *
 */
abstract class BaseWidget extends Composite {

	protected WidgetEventHandler iEventHandler;
	
	protected BaseWidget(){
		
	}
	
	protected BaseWidget(WidgetEventHandler aEventHandler){
		iEventHandler = aEventHandler;
	}
	
	public void setWidgetEventHandler(WidgetEventHandler aEventHandler){
		iEventHandler = aEventHandler;
	}
	
	protected void postEvent(WidgetEventType aType){
		
		if(iEventHandler != null){
			iEventHandler.handleWidgetEvent(aType);
		}
	}
	
	protected WidgetEventHandler getWidgetEventHandler(){
		return iEventHandler;
	}
	
}
